1 /*
2 * Copyright (C) 2007 The Guava Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.google.common.collect;
18
19 import com.google.common.annotations.GwtCompatible;
20
21 import java.util.ListIterator;
22
23 /**
24 * A list iterator which forwards all its method calls to another list
25 * iterator. Subclasses should override one or more methods to modify the
26 * behavior of the backing iterator as desired per the <a
27 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
28 *
29 * @author Mike Bostock
30 * @since 2.0 (imported from Google Collections Library)
31 */
32 @GwtCompatible
33 public abstract class ForwardingListIterator<E> extends ForwardingIterator<E>
34 implements ListIterator<E> {
35
36 /** Constructor for use by subclasses. */
37 protected ForwardingListIterator() {}
38
39 @Override protected abstract ListIterator<E> delegate();
40
41 @Override
42 public void add(E element) {
43 delegate().add(element);
44 }
45
46 @Override
47 public boolean hasPrevious() {
48 return delegate().hasPrevious();
49 }
50
51 @Override
52 public int nextIndex() {
53 return delegate().nextIndex();
54 }
55
56 @Override
57 public E previous() {
58 return delegate().previous();
59 }
60
61 @Override
62 public int previousIndex() {
63 return delegate().previousIndex();
64 }
65
66 @Override
67 public void set(E element) {
68 delegate().set(element);
69 }
70 }